package com.gcd.alienandwheel.actor;

import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;

/**
 *
 * @author user
 */
public abstract class MyActor extends Actor {

    public Texture texture;
    public TextureRegion textureRegion;
    public Pixmap pixmapTexture;

    public MyActor(String name) {
        super(name);
    }

    @Override
    protected void draw(SpriteBatch batch, float parentAlpha) {
        batch.draw(textureRegion, x, y, originX, originY, width, height, scaleX, scaleY, rotation);
    }

    @Override
    protected boolean touchDown(float x, float y, int pointer) {
        return false;
    }

    @Override
    protected boolean touchUp(float x, float y, int pointer) {
        return false;
    }

    @Override
    protected boolean touchDragged(float x, float y, int pointer) {
        return false;
    }

    @Override
    public Actor hit(float x, float y) {
        return null;
    }

    public void setTexture(FileHandle fileHandle) {
        pixmapTexture = new Pixmap(fileHandle);
        setTexture(pixmapTexture);
    }
    
    public void setTexture(Pixmap pixmapTexture) {
        this.pixmapTexture = pixmapTexture;
        texture = new Texture(pixmapTexture);
        textureRegion = new TextureRegion(texture);
        
        width = texture.getWidth();
        height = texture.getHeight();
        originX = width / 2;
        originY = height / 2;
    }
}
